#ifndef SERIALPORT_H
#define SERIALPORT_H

#include <QObject>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QDebug>
#include <QMap>

class SerialPort : public QObject
{
    Q_OBJECT
public:
    explicit SerialPort(QObject *parent = nullptr);

    void setSerialPort(QSerialPort *serial, const QString &portName);

    void openAllCOM();

    bool sendData(const QString &ComName, const QByteArray &data);

    void printSerialPorts();
signals:
    void dataRecv(const QString &ComName, const QByteArray &data);
public slots:
    void readFromSerial();
private:
    QMap<QString, QSerialPort*> serialPorts;
};

#endif // SERIALPORT_H
